package com.atguigu.tingshu.user.rpc;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.user.service.VipServiceConfigService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/api/userInfo/rpc")
public class UserInfoRpcController {
    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private VipServiceConfigService vipServiceConfigService;

    @GetMapping("/getUserInfoByUserId/{userId}")
    Result<UserInfoVo> getUserInfoByUserId(@PathVariable("userId") Long userId){
        UserInfoVo userInfoVo = userInfoService.getUserInfoVo(userId);
        return Result.ok(userInfoVo);
    }
    @GetMapping("/getUserPaidAlbumTrackList/{albumId}/{userId}")
    Result<Map<Long, String>> getUserPaidAlbumTrackList(@PathVariable("albumId") Long albumId, @PathVariable("userId") Long userId){
        Map<Long, String> map = userInfoService.getUserPaidAlbumTrackList(albumId, userId);
        return Result.ok(map);
    }

    @GetMapping("/getUserPaidAlbum/{albumId}/{userId}")
    Result<Boolean> getUserPaidAlbum(@PathVariable("albumId") Long albumId, @PathVariable("userId") Long userId){
        Boolean flag= userInfoService.getUserPaidAlbum(albumId, userId);
        return Result.ok(flag);
    }


    @GetMapping("/getVipServiceConfig/{itemId}")
    Result<VipServiceConfig> getVipServiceConfig(@PathVariable("itemId") Long itemId){
        VipServiceConfig vipServiceConfig = vipServiceConfigService.getVipServiceConfig(itemId);
        return Result.ok(vipServiceConfig);
    }

}
